<template>
<div style="height: 80vh;padding: 10px 10px;">
<el-table align="1" :data="noticeTable">
  <el-table-column prop="releaseTime" label="发布时间"/>
  <el-table-column prop="releaseTitle" label="发布主题"/>
  <el-table-column prop="releaseName" label="发布人"/>
  <el-table-column label="操作">
    <template #default="scope">
      <el-button type="text" size="small" @click="details(scope.row.id)">详情</el-button>
    </template>
  </el-table-column>
</el-table>
</div>
</template>

<script setup>
import {onMounted, ref} from "vue";
import axios from "axios";
import {ElMessage} from "element-plus";
import router from "@/router";
//
const noticeTable = ref([]);
//一打开页面就加载公告列表
onMounted(()=>{
  loadNotice();
})
//定义加载公告列表的方法
const loadNotice = ()=>{
  axios.get(BASE_URL+'/api/notice/select').then((response)=>{
    if(response.data.code==2000){
      noticeTable.value = response.data.data;
      console.log(noticeTable.value);
    }else{
      ElMessage.error(response.data.msg);
    }
  })
}
//定义查看详情的方法
const details = (id)=>{
  router.push('/noticeDetails');
}
</script>

<style scoped>

</style>


